﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MemberPoint.Entity.POCOModels;
using MemberPoint.Entity.ViewModels.LoginViewModel;
using MemberPoint.Business;

namespace MemberPoint.Web.Controllers
{
    public class LoginController : Controller
    {
        // GET: Login
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 跳转登录页面
        /// </summary>
        /// <returns></returns>
        #region
        public ActionResult Login()
        {
            return View();
        }
        #endregion

        /// <summary>
        /// 登录方法
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        #region
        public ActionResult IsLogin(LoginViewModel model)
        {
            LoginService db = new LoginService();
            return Json(db.Login(model));
        }
        #endregion

        /// <summary>
        /// 跳转Home页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        #region
        public ActionResult Home(int id)
        {
            return View();
        }
        #endregion

        /// <summary>
        /// 跳转修改密码页面
        /// </summary>
        /// <returns></returns>
        #region
        public ActionResult UpdatePwd()
        {
            return View();
        }
        #endregion

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        #region
        public ActionResult UpdatePassword(UpdatePasswordViewModel model)
        {
            try
            {
                LoginService db = new LoginService();
                return Json(db.UpdatePwd(model));
            }
            catch
            {
                return View("UpdatePwd");
            }
        }
        #endregion

        /// <summary>
        /// 跳转修改信息页面
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        #region
        public ActionResult UpdateInfo(UpdateInfoViewModel model)
        {
            LoginService db = new LoginService();
            return View(db.Info(model));
        }
        #endregion

        /// <summary>
        /// 修改个人信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        #region
        public ActionResult UpdateUserInfo(UpdateInfoViewModel model)
        {
            try
            {
                LoginService db = new LoginService();
                return Json(db.UpdateInfo(model));
            }
            catch
            {
                return View("UpdateInfo");
            }
        }
        #endregion
    }
}